from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated
from apps.users.models import User
from datetime import date

class DailyActiveAPIView(APIView):
    # permission_classes = [IsAuthenticated]

    def get(self,request):
        today = date.today()
        count = User.objects.filter(last_login__gte=today).count()
        return Response({'count':count,'now_date':today})

class DailyOrderCountAPIView(APIView):
    def get(self,request):
        today=date.today()
        count=User.objects.filter(orderinfo__create_time__gte=today).count()
        return Response({'count':count,'now_date':today})